package jpm.common;

import jpm.common.JPMException.ErrorCode;

public class Utils {
		
	public static int safeParseAsInt(String s) {
		try {
			int i = Integer.parseInt(s);
			return i;
		} catch (NumberFormatException e) {
			throw new JPMException().errorCode(ErrorCode.ERROR_INVALID_INPUT)
					.message("Cannot parse [" + s + "] as integer");
		}
	}

	public static boolean canParseAsInt(String s) {
		try {
			safeParseAsInt(s);
			return true;
		} catch (Exception ex) {
			return false;
		}
	}	
}
